package com.ruoyi.web.controller.notificationSettings;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MemberSmsNotification;
import com.ruoyi.system.service.IMemberSmsNotificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员短信通知配置，定义短信类型、推送开关及用途描述Controller
 *
 * @author ruoyi
 * @date 2025-05-13
 */
@Api(tags="会员短信通知配置")
@RestController
@RequestMapping("/system/memberSmsNotification")
public class MemberSmsNotificationController extends BaseController
{
    @Autowired
    private IMemberSmsNotificationService memberSmsNotificationService;

    /**
     * 查询会员短信通知配置列表
     */
    @ApiOperation("查询会员短信通知配置列表")
    @PreAuthorize("@ss.hasPermi('system:notification:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberSmsNotification memberSmsNotification)
    {
        startPage();
        List<MemberSmsNotification> list = memberSmsNotificationService.selectMemberSmsNotificationList(memberSmsNotification);
        return getDataTable(list);
    }

    /**
     * 导出会员短信通知配置列表
     */
    @ApiOperation("导出会员短信通知配置列表")
    @PreAuthorize("@ss.hasPermi('system:notification:export')")
    @Log(title = "会员短信通知配置，定义短信类型、推送开关及用途描述", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberSmsNotification memberSmsNotification)
    {
        List<MemberSmsNotification> list = memberSmsNotificationService.selectMemberSmsNotificationList(memberSmsNotification);
        ExcelUtil<MemberSmsNotification> util = new ExcelUtil<MemberSmsNotification>(MemberSmsNotification.class);
        util.exportExcel(response, list, "会员短信通知配置，定义短信类型、推送开关及用途描述数据");
    }

    /**
     * 通过id获取会员短信通知配置详细信息
     */
    @ApiOperation("通过id获取会员短信通知配置详细信息")
    @PreAuthorize("@ss.hasPermi('system:notification:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memberSmsNotificationService.selectMemberSmsNotificationById(id));
    }

    /**
     * 新增会员短信通知配置
     */
    @ApiOperation("新增会员短信通知配置")
    @PreAuthorize("@ss.hasPermi('system:notification:add')")
    @Log(title = "会员短信通知配置，定义短信类型、推送开关及用途描述", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberSmsNotification memberSmsNotification)
    {
        return toAjax(memberSmsNotificationService.insertMemberSmsNotification(memberSmsNotification));
    }

    /**
     * 修改会员短信通知配置
     */
    @ApiOperation("修改会员短信通知配置")
    @PreAuthorize("@ss.hasPermi('system:notification:edit')")
    @Log(title = "会员短信通知配置，定义短信类型、推送开关及用途描述", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberSmsNotification memberSmsNotification)
    {
        return toAjax(memberSmsNotificationService.updateMemberSmsNotification(memberSmsNotification));
    }

    /**
     * 通过id批量删除会员短信通知配置信息
     */
    @ApiOperation("通过id批量删除会员短信通知配置信息")
    @PreAuthorize("@ss.hasPermi('system:notification:remove')")
    @Log(title = "会员短信通知配置，定义短信类型、推送开关及用途描述", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberSmsNotificationService.deleteMemberSmsNotificationByIds(ids));
    }
}
